<html>
    <head>
        <title>Reporte alquiler en periodo de tiempo</title>
        <?php
        
        $arAlquileres="";
        /*
         * To change this template, choose Tools | Templates
         * and open the template in the editor.
         */
        include_once("../control/ControlAlquiler.php");
        session_start();
        $fechaini = $_GET['from'];
        $fechafin = $_GET['to'];
        if ($fechaini != null && $fechafin != null) {
            $cAlquiler = new ControlAlquiler();
//Esto nos ha guardado los datos en las variables de sesion
            $cAlquiler->getReporteAlquileres($fechaini, $fechafin);
            $arAlquileres = $_SESSION['arAlquileres'];
        }
        
        ?>
        <script type="text/javascript" src="<?php dirname(__FILE__) ?>/alquilerdonquijote/js/jquery.js"></script>
        <script type="text/javascript" src="<?php dirname(__FILE__) ?>/alquilerdonquijote/js/jquery-validate/jquery.validate.js"></script>
        <script type="text/javascript" src="<?php dirname(__FILE__) ?>/alquilerdonquijote/js/jquery-ui-1.8.5.custom.min.js"></script>
        <script type="text/javascript" src="<?php dirname(__FILE__) ?>/alquilerdonquijote/js/jquery.dataTables.js"></script>
        <script type="text/javascript" src="<?php dirname(__FILE__) ?>/alquilerdonquijote/js/ColReorder.js"></script>
        <script type="text/javascript" src="<?php dirname(__FILE__) ?>/alquilerdonquijote/js/scripts.js"></script>

        <link rel="stylesheet" type="text/css" media="screen" href="<?php dirname(__FILE__) ?>/alquilerdonquijote/css/estilo.css" />
            <link rel="stylesheet" type="text/css" media="screen" href="<?php dirname(__FILE__) ?>/alquilerdonquijote/css/start/jquery-ui-1.8.5.custom.css" />	
        <!--<link rel="stylesheet" type="text/css" media="screen" href="<?php dirname(__FILE__) ?>/alquilerdonquijote/css/styles.css"  type="text/css" /> -->
        <link rel="stylesheet" type="text/css" media="screen" href="<?php dirname(__FILE__) ?>/alquilerdonquijote/css/demo_table_jui.css"  type="text/css" />
        <link rel="stylesheet" type="text/css" media="screen" href="<?php dirname(__FILE__) ?>/alquilerdonquijote/css/smoothness/jquery-ui-1.8.4.custom.css"  type="text/css" />
        <link rel="stylesheet" type="text/css" media="screen" href="<?php dirname(__FILE__) ?>/alquilerdonquijote/css/ColReorder.css"  type="text/css" /> 

        <script type="text/javascript" language="javascript">
        
            
            $(function() {
                var dates = $( "#from, #to" ).datepicker({
                    changeMonth: true,
                    numberOfMonths: 1,
                    dateFormat: 'yy-mm-dd',
                    onSelect: function( selectedDate ) {
                        
                        var option = this.id == "from" ? "minDate" : "maxDate",
                        instance = $( this ).data( "datepicker" ),
                        date = $.datepicker.parseDate(
                        instance.settings.dateFormat ||
                            $.datepicker._defaults.dateFormat,
                        selectedDate, instance.settings );
                        dates.not( this ).datepicker( "option", option, date );
                    }
                });
            });
             
            $(document).ready( function () {
                var oTable = $('#tablaAlquileres').dataTable( {
                    "sDom": 'R<"H"lfr>t<"F"ip>',
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers",
                    "bPaginate": true,
                    "bLengthChange": true,
                    "bFilter": true,
                    "bSort": true,
                    "bInfo": true,
                    "bAutoWidth": true,
                    "aaSorting": [[ 0, "desc" ]]
                } );
            } );
        </script>
    </head>
    <body>
        <h1 style="padding-left: 10px;">Reporte Alquileres Realizados en periodo de tiempo</h1>
        <p>&nbsp;</p>
        <div style="padding-left: 20px;">
            <form action="ReporteAlquilerRealizado.php" method="get">
                <label for="from">Desde</label>
                <input type="text" id="from" name="from" value="<?php echo $fechaini ?>"/>
                <label for="to">Hasta</label>
                <input type="text" id="to" name="to" value="<?php echo $fechafin ?>" />
                <input type="submit" value="Generar" />
            </form>
        </div>
        <div style="width: 1010px; padding-left: 20px;"> 
            <table id="tablaAlquileres" class="tabla_datos">
                <thead>
                    <tr>
                        <th scope="col">Fecha Alquiler</th>
                        <th scope="col">Fecha Cierre</th>
                        <th scope="col">Nombre </th>
                        <th scope="col">Placa</th>
                        <th scope="col">Sucursal Alquiler</th>
                        <th scope="col">Sucursal Entrega</th>
                    </tr>
                </thead>
                <tbody>

                    <?php
                    if ($arAlquileres != null) {
                        foreach ($arAlquileres as $oAlquiler) {
                            ?>
                            <tr>
                                <td><?php echo $oAlquiler->alqfechaini ?></td>
                                <td><?php echo $oAlquiler->alqfechafin ?></td>
                                <td><?php echo $oAlquiler->usunombre . ' ' . $oAlquiler->usuapellido ?></td>
                                <td><?php echo $oAlquiler->vehiplaca ?></td>
                                <td><?php echo $oAlquiler->sucursalini ?></td>
                                <td><?php echo $oAlquiler->sucursafin ?></td>
                            </tr>
                            <?php
                        }
                    }
                    ?>
                </tbody>

            </table>
        </div>
    </body>
</html>       